import http from '@/service/http';
import type { RootObject } from './types/rootObject';
import type { LoginData, LogoutData, RoutesData } from './types/user';

export const login = (data: any) => {
    return http.post<RootObject<LoginData>>('/login', data);
};

export const logout = () => {
    return http.post<RootObject<LogoutData>>('/logout');
};
export const getRoutes = () => {
    return http.get<RootObject<RoutesData>>(
        '/getRoutes',
        {},
        {
            // 请求拦截
            requestInterceptors(config) {
                return config;
            },
            // 响应拦截
            responseInterceptors(res) {
                //单个请求拦截属于最末位 res为后台返回的信息
                return res;
            }
        }
    );
};
